package com.capgemini.simpleappblanche.utils.mock;

import java.util.ArrayList;
import java.util.List;

import com.capgemini.simpleappblanche.domain.Agency;
import com.capgemini.simpleappblanche.domain.customer.Customer;
import com.capgemini.simpleappblanche.dto.SearchCustomerCriteria;
import com.capgemini.simpleappblanche.dto.enumeration.Title;


public class CustomerMockEntities {

	
	public static List<Customer> getCustomers(){
		final List<Customer> customers= new ArrayList<Customer>();
		
		List<Agency> agencies = new ArrayList<Agency>();
		Agency agency = new Agency();
		agency.setId(new Long(1));
		agency.setName("LILLE");
		agency.setActive(Boolean.TRUE);
		agencies.add(agency);
		
		Customer customer;
		
		customer = new Customer();
		customer.setId(new Long(1));
		customer.setTitle(Title.MR);
		customer.setName("DUPOND");
		customer.setFirstname("Martin");
		customer.setAgencies(agencies);
		customers.add(customer);
		
		customer = new Customer();
		customer.setId(new Long(2));
		customer.setTitle(Title.MR);
		customer.setName("DUPOND");
		customer.setFirstname("Henri");
		customer.setAgencies(agencies);
		customers.add(customer);
		
		customer = new Customer();
		customer.setId(new Long(3));
		customer.setTitle(Title.MR);
		customer.setName("GARCIA");
		customer.setFirstname("José");
		customer.setAgencies(agencies);
		customers.add(customer);
		
		customer = new Customer();
		customer.setId(new Long(4));
		customer.setTitle(Title.MRS);
		customer.setName("LAMY");
		customer.setFirstname("Alexandra");
		customer.setAgencies(agencies);
		customers.add(customer);
		
		return customers;
	}

	public static Customer getCustomerById(Long id) {
		List<Customer> customers = CustomerMockEntities.getCustomers();
		
		for(Customer customer : customers){
			if(id.equals(customer.getId())){
				return customer;
			}
		}
		return null;
	}

	public static List<Customer> getCustomerByCriteria(
			SearchCustomerCriteria criteria) {
		List<Customer> customers = CustomerMockEntities.getCustomers();
		List<Customer> result = new ArrayList<Customer>();
		
		for(Customer customer : customers){
			if(criteria.getName().equals(customer.getName())){
				result.add(customer);
			}
		}
		return result;
	}
	
}
